﻿using IntegrationTests.Core;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.CSharp.Tree;
using Moq;
using TechTalk.SpecFlow;
using Twins.Classes;
using Twins.Infrastructure;

namespace IntegrationTest.Definitions.DuplicationDifferentMethods
{
    [Binding]
    public class DuplicationDifferentMethodsDefinition
    {
        private ICSharpFile treeCSharpFile;
        private DispatherProject dispatherProject;

        public DuplicationDifferentMethodsDefinition()
        {
            IoC.Initialize();
            var psiSourceFile = new Mock<IPsiSourceFile>();
            psiSourceFile.Setup(x => x.IsValid()).Returns(true);
            dispatherProject = IoC.Resolve<DispatherProject>();
            dispatherProject.CreateFile(psiSourceFile.Object);
        }

        [Given(@"два метода (.*)")]
        public void ФормированиеДерева(string code)
        {
            var source = "namespace Test{ class MyClass{public void Test(){" + code + "}" +
                         "public void Test1(){" + code + "}" + "}}";
            treeCSharpFile = CreaterTreeCSharpFile.CreateTreeCSharpFile(source);
        }

        [Then("вызвать функция подчеркивания дублирования (.*)")]
        public void ВызватьФункцияПодчеркиванияДублирования(int count)
        {
            //var highlightingConsumer = new Mock<IHighlightingConsumer>();
            //highlightingConsumer.Setup(x => x.AddHighlighting(null, null, null, null));
            //dispatherProject.LookCSharpFile(highlightingConsumer.Object, treeCSharpFile);

            //highlightingConsumer.Verify(
            //    x => x.AddHighlighting(null, null, null, null),
            //    Times.Exactly(count));
        }
    }
}
